/**Author:7rATM Team
 * Date:May 2009
 * Description: The class Client extends class Persion and provide some function to  * users
 */

package AtmSystem;

import java.util.*;

public class Client extends Person
{   
	private int userID;
	private String username;
	private String password;
	private String email;	
	private BankAccountDB myBankAccountDB;
	private BankAccount currentBankAccount;

    /**
     * Constructs a <code>Book</code> object.
     *
     * @param initialUserID  the ID of the user.
     * @param initialUsername  the name of the user.
     * @param initialYear  the year the book was published.
     * @param initialPassword  the password of account.
     * @param initialEmail  the email of user.
     */
	public Client(int initialUserID, String initialUsername,String initialPassword,String initialEmail)
	{
        super(initialUserID,initialUsername, initialPassword,initialEmail);
		myBankAccountDB = new BankAccountDB();
	}

    /**
     * Returns the BankAccountDB.
     *
     * @return  BankAccountDB.
     */
	 public BankAccountDB getBankAccountDB()
	 {
		 return myBankAccountDB;
	 }

    /**
     * Returns the currentBankAccount.
     *
     * @return  currentBankAccount.
     */
	 public BankAccount getCurrentBankAccount()
	{
		 return currentBankAccount;
	 }

    /**
     * Sets the value of instance variable <code>newCardNumber</code>.
     *
     * @param newCardNumber  the new card number.
     */
	 public void setCurrentBankAccount(int newCardNumber)
	{
		 currentBankAccount = getBankAccountDB().isExsit(newCardNumber);
	 }

	

	/**
         *  add newCardNumber and newBalance to 
	 *        BankAccountDB if balance>=zero.
         *
         *@return <code>ture</code> if newBalance >= 0 ;
	 *    return  <code>false</code>otherwises.
         */	
	public BankAccount addBankAccount(int newCardNumber,double newBalance)
	{
		if(newBalance >= 0)
		{
			BankAccount myBankAccount = new BankAccount(newCardNumber,newBalance);
		myBankAccountDB.add(myBankAccount);
        return myBankAccount;
		}
		else 
		return null;
	}

      /**
       * remove newCardNumber  to BankAccountDB if users' ID is equals to
       * a ID in BankAccountDB
       *
       * @return <code>ture</code> if users' ID is equals to
       * a ID in BankAccountDB
       * return  <code>false</code>otherwises.
       */
	public boolean removeBankAccount(int newCardNumber)
		{
      return myBankAccountDB.removeb(newCardNumber);
		}

		public boolean equals(Client newClient)
	{
			if ( getUserID()== newClient.getUserID()  )
			{
				return true;
			}
			else return false;
		}


}


